package com.company.笔试.调整数组顺序;

import java.util.*;


public class SolutionNew {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param array int整型一维数组 
     * @return int整型一维数组
     */
    public int[] reOrderArray (int[] array) {
        // write code here
        if(array.length == 0 || array.length==1) return array;
        int [] res = new int [array.length]; //
        int left = 0;
        int right = array.length-1;
        for(int i = 0,j = array.length-1;left<=right;i++,j--){
            if(array[i]%2!=0){
                res[left++] = array[i];
            }
            if(array[j]%2==0){
                res[right--] = array[j];
            }
        }
        
        return res;
        
    }
}